/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.UCServiceBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.UCService;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RenameUCService
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 39 */     ZimbraSoapContext lc = getZimbraSoapContext(context);
/* 40 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 42 */     String id = request.getElement("id").getText();
/* 43 */     String newName = request.getElement("newName").getText();
/*    */     
/* 45 */     UCService ucService = prov.get(Key.UCServiceBy.id, id);
/* 46 */     if (ucService == null) {
/* 47 */       throw AccountServiceException.NO_SUCH_UC_SERVICE(id);
/*    */     }
/*    */     
/*    */ 
/* 51 */     checkRight(lc, context, ucService, Rights.Admin.R_renameUCService);
/*    */     
/* 53 */     String oldName = ucService.getName();
/*    */     
/* 55 */     prov.renameUCService(id, newName);
/*    */     
/* 57 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameUCService", "name", oldName, "newName", newName }));
/*    */     
/*    */ 
/*    */ 
/*    */ 
/* 62 */     ucService = prov.get(Key.UCServiceBy.id, id);
/* 63 */     if (ucService == null) {
/* 64 */       throw ServiceException.FAILURE("unabled to get renamed uc service: " + id, null);
/*    */     }
/* 66 */     Element response = lc.createElement(AdminConstants.RENAME_UC_SERVICE_RESPONSE);
/* 67 */     GetUCService.encodeUCService(response, ucService, null, null);
/* 68 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 73 */     relatedRights.add(Rights.Admin.R_renameUCService);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RenameUCService.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */